/**
 * @description 登录 登出等功能
 * @author cx
 * @date 2024.10.17 13:54
 */


package com.cx.controller;

import com.cx.entity.PUser;
import com.cx.entity.RestResp;
import com.cx.service.serviceimp.PUserServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class LoginController {
    @Resource
    private PUserServiceImpl pUserService;


    //    根据账号密码登录
    @PostMapping("/login")
    public RestResp login(@RequestBody PUser pUser) {
        PUser login = pUserService.login(pUser);
        if (login != null) {
            return RestResp.success(login.getId());
        } else {
            return RestResp.error("账号或者密码错误");
        }
    }


}
